# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Kyle Keen <keenerd@gmail.com>

pkgname=jupyter-nbconvert
_name=nbconvert
pkgver=7.3.1
pkgrel=3
pkgdesc='Jupyter Notebook Conversion'
arch=(any)
url='https://pypi.python.org/pypi/nbconvert'
license=(BSD)
depends=(jupyter-nbformat jupyter-nbclient jupyterlab_pygments
         python-beautifulsoup4 python-bleach python-defusedxml python-entrypoints python-jinja python-pandocfilters
         python-mistune python-pygments python-traitlets python-tinycss2 python-lxml)
makedepends=(python-build python-installer python-hatchling python-pyppeteer)
checkdepends=(python-pytest python-ipywidgets)
optdepends=('pandoc: non-html conversion output'
            'python-pyppeteer: for webPDF conversion support')
source=(https://github.com/jupyter/nbconvert/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('a3113cddd4f578498d6f476375938d4dedbfd8f6036abe3926e72cf9e8e266d6')

build() {
  cd nbconvert-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd nbconvert-$pkgver
  export PYTHONPATH="$PWD" # Make sure system nbconvert is not used
  # disable tests that download chromium and (probably) require a graphical session
  pytest -v -k 'TestWebPDFExporter and not (test_export or test_webpdf_without_pyppeteer)' -W ignore::DeprecationWarning
  pytest -v -k 'TestNbConvertApp and not test_webpdf_with_chromium' -W ignore::DeprecationWarning
  # run all remaining tests
  pytest -v -k 'not TestWebPDFExporter and not TestNbConvertApp' -W ignore::DeprecationWarning
}

package() {
  cd nbconvert-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}
